<%@page import="com.df.springmvc.workflow.deploy.controller.DeployManageController"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("basePath", basePath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>查看流程图</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<jsp:include page="/scripts/common/index.html"></jsp:include>
<jsp:include page="/scripts/dhtmlx/index.html"></jsp:include>
<jsp:include page="/scripts/jquery/index.html"></jsp:include>
<jsp:include page="/scripts/bootstrap/index.html"></jsp:include>
<link rel="stylesheet" href="${basepath }style/default.css">
</head>
<script type="text/javascript">
	var temp = false;
	function closeWindow() {
		parent.w1.close();
	}
	function getInfo(obj) {
		var o = $("#" + obj);
		$("#defId").text(o.attr("defId"));
		$("#taskId").text(o.attr("id"));
		$("#taskName").text(o.attr("name"));
		$("#assignee").text(o.attr("assignee"));
		$("#candidateGroups").text(o.attr("candidateGroups"));
		$("#candidateUsers").text(o.attr("candidateUsers"));
		$("#collection").text(o.attr("collection"));
		var defId = $("#defId").text();
		var taskId = $("#taskId").text();
		var url = '${basePath}page/workflow/deploy/DeployManage/queryFormInfo';
		var data = {
				"map.defId" : defId ,
				"map.taskId" : taskId
		};
		$.ajax({
				type : 'POST' ,
				url : url ,
				data : data ,
				dataType : "json" ,
				async : true ,
				cache : false ,
				jsonpCallback : "jsonpCallback" ,
				success : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
					if (response.status) {
						var o = response.content;
						$("#url").val(o["url"]);
						if (o["name"] == "") {
							$("#name").val($("#taskName").text());
						} else {
							$("#name").val(o["name"]);
						}
						$("#name").val(o["name"]);
						if (o["w"] == "") {
							$("#w").val(800);
						} else {
							$("#w").val(o["w"]);
						}
						if (o["h"] == "") {
							$("#h").val(600);
						} else {
							$("#h").val(o["h"]);
						}
					} else {
						alert(response.content);
					}
				}
		});
	}
	function auto() {
		var defId = $("#defId").text();
		var taskId = $("#taskId").text();
		if ("" == defId) {
			alert("请选择一个任务");
			return;
		}
		var url = '${basePath}page/workflow/deploy/DeployManage/doAuto';
		var data = {
				"map.defId" : defId ,
				"map.taskId" : taskId ,
				"map.url" : $("#url").val() ,
				"map.name" : $("#name").val() ,
				"map.w" : $("#w").val() ,
				"map.h" : $("#h").val()
		};
		$.ajax({
				type : 'POST' ,
				url : url ,
				data : data ,
				dataType : "json" ,
				async : true ,
				cache : false ,
				jsonpCallback : "jsonpCallback" ,
				success : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
					if (response.status) {
						var o = response.content;
						$("#url").val(o["url"]);
						if (o["name"] == "") {
							$("#name").val($("#taskName").text());
						} else {
							$("#name").val(o["name"]);
						}
						$("#name").val(o["name"]);
						if (o["w"] == "") {
							$("#w").val(800);
						} else {
							$("#w").val(o["w"]);
						}
						if (o["h"] == "") {
							$("#h").val(600);
						} else {
							$("#h").val(o["h"]);
						}
						save();
					} else {
						alert(response.content);
					}
				}
		});
	}
	function save() {
		var defId = $("#defId").text();
		var taskId = $("#taskId").text();
		if ("" == defId) {
			alert("请选择一个任务");
			return;
		}
		var url = '${basePath}page/workflow/deploy/DeployManage/doConfig';
		var data = {
				"map.defId" : defId ,
				"map.taskId" : taskId ,
				"map.url" : $("#url").val() ,
				"map.name" : $("#name").val() ,
				"map.w" : $("#w").val() ,
				"map.h" : $("#h").val()
		};
		$.ajax({
				type : 'POST' ,
				url : url ,
				data : data ,
				dataType : "json" ,
				async : true ,
				cache : false ,
				jsonpCallback : "jsonpCallback" ,
				success : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
					alert(response.content);
				}
		});
	}
</script>
<style>
.form-group{
margin-bottom: 0px;
}
.form-group>div{
text-align: left;
margin-top: 4px;
}
.form-group>.col-xs-4{
width: 31.3%;
}
</style>
<body style="width: 100%;height: 100%;margin: 0;border: 0;">
	<form style="width: 100%;height: 99%;margin: 0;" class="form-horizontal MyForm" id="MyForm" name="MyForm" method="post" target="MyFrame" enctype="multipart/form-data">
		<table class="contTable" style="width: 100%;height: 100%;" border="0">
			<tr class="firstTr" style="height: 40px;">
				<td>
					<button onclick="save()" class="btn btn-primary" type="button">
						<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
						&nbsp;
						<span>保存</span>
					</button>
					<button onclick="auto()" class="btn btn-primary" type="button">
						<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
						&nbsp;
						<span>自动识别</span>
					</button>
					<button onclick="closeWindow()" class="btn btn-primary" type="button">
						<span class="glyphicon glyphicon-remove-sign" aria-hidden="true"></span>
						&nbsp;
						<span>关闭</span>
					</button>
				</td>
			</tr>
			<tr style="height:auto;">
				<td valign="top" style="width: 100%;height: 300px;">
					<div class="blockBorder" style="width: 100%;height:280px;border: 0;overflow: auto;">
						<table id="time_table" class="table table-striped table-bordered" style="margin-top: 0px;">
							<thead align="center">
								<tr style="background:#f0efef" class="childTitle">
									<th>流程节点</th>
									<th>属性</th>
								</tr>
							</thead>
							<tbody align="center" class="childTable" id="mytr">
								<tr class="childCont" id="tr_1">
									<td style="width: 130px;" valign="top">
										<div class="col-xs-12">
										<c:forEach items="${info }" var="item">
											<a href="javascript:" onclick="getInfo('${item.id }')")>
												<div style="line-height: 20px;text-align: left;" id="${item.id }" name="${item.name }" defId="${item.defId }" assignee="${item.assignee }" candidateGroups="${item.candidateGroups }" candidateUsers="${item.candidateUsers }" collection="${item.collection }">${item.id }(${item.name })</div>
											</a>
										</c:forEach>
										</div>
									</td>
									<td>
										<div class="col-xs-12 ">
											<div class="form-group">
												<label class="col-xs-3 control-label">流程定义编号:</label>
												<div class="col-xs-3 ">
													<span id="defId" style="width: 100%"> </span>
												</div>
												
											</div>
											<div class="form-group">
												<label class="col-xs-3 control-label">任务编号:</label>
												<div class="col-xs-3">
													<span id="taskId"> </span>
												</div>
												<label class="col-xs-2 control-label">任务名称:</label>
												<div class="col-xs-3">
													<span id="taskName"> </span>
												</div>
												
												
											</div>
											<div class="form-group">
												<label class="col-xs-3 control-label">处理人:</label>
												<div class="col-xs-3 ">
													<span id="assignee"> </span>
												</div>
												<label class="col-xs-2 control-label">候选组:</label>
												<div class="col-xs-3">
													<span id="candidateGroups"> </span>
												</div>
												
											</div>
											<div class="form-group">
												<label class="col-xs-3 control-label">候选人:</label>
												<div class="col-xs-3 ">
													<span id="candidateUsers"> </span>
												</div>
												<label class="col-xs-2 control-label">会签人:</label>
												<div class="col-xs-3 ">
													<span id="collection"> </span>
												</div>
											</div>
											<div class="form-group">
												<label class="col-xs-3 control-label">关联表单名称:</label>
												<div class="col-xs-8 ">
													<input class=" form-control" id="name" type="text" placeholder="" />
												</div>
											</div>
											<div class="form-group">
												<label class="col-xs-3 control-label">关联表单大小(w*h):</label>
												<div class="col-xs-4 ">
													<input class=" form-control" id="w" type="text" placeholder="" />
												</div>
												<label class="col-xs-1" style="text-align: center;line-height: 20px;">*</label>
												<div class="col-xs-4">
													<input class=" form-control" id="h" type="text" placeholder="" />
												</div>
											</div>
											<div class="form-group">
												<label class="col-xs-3 control-label">关联表单URL:</label>
												<div class="col-xs-8 ">
													<input class=" form-control" id="url" type="text" placeholder="" />
												</div>
											</div>
										</div>
									</td>
								</tr>
							</tbody>
									
						</table>
					</div>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
